<?php


namespace app\bonus\logic;


class DealParamLogic
{
    /**
     * 处理商铺字段
     * @param $data
     * @return mixed
     */
    public static function dealShopPram($data,$type = "add"){
        if($type== "add") $rdata['login_name'] = $data['login_name'];
        if($type== "add") $rdata['login_pass'] = md5($data['password']);
        $rdata['name'] = $data['name'];
        $rdata['contacts'] = $data['contacts'];
        $rdata['contacts_tel'] = $data['contacts_tel'];
        $rdata['address'] = $data['address'];
        $rdata['lng'] = $data['lng'];
        $rdata['lat'] = $data['lat'];
        $rdata['province'] = $data['province'];
        $rdata['city'] = $data['city'];
        $rdata['district'] = $data['district'];
        $rdata['town'] = $data['town'];
        $rdata['yh_zhihang'] = $data['yh_zhihang'];
        $rdata['yh_zhanghao'] = $data['yh_zhanghao'];
        return $rdata;
    }

    /**
     * 数据优惠券处理
     * @param $data
     * @return mixed
     */
    public static function dealCouponParam($data){
        $rdata['name'] = $data['name'];
        $rdata['color'] = $data['color']?$data['color']:0;
        $rdata['lq_type'] = $data['lq_type']?$data['lq_type']:0;
        $rdata['coupon_type'] = $data['coupon_type']?$data['coupon_type']:0;
        $rdata['reduce_price'] = $data['reduce_price']?$data['reduce_price']:0;
        $rdata['discount'] = $data['discount']?$data['discount']:0;
        $rdata['min_price'] = $data['min_price']?$data['min_price']:0;
        $rdata['expire_type'] = $data['expire_type']?$data['expire_type']:0;
        $rdata['expire_day'] = $data['expire_day']?$data['expire_day']:0;
        $rdata['start_time'] = $data['start_time']?strtotime($data['start_time']):0;
        $rdata['end_time'] = $data['end_time']?strtotime($data['end_time']):0;
        $rdata['apply_range'] = $data['apply_range']?($data['apply_range']):0;
        $rdata['total_num'] = $data['total_num']?($data['total_num']):0;
        $rdata['receive_num'] = $data['receive_num']?($data['receive_num']):0;
        $rdata['sort'] = $data['sort']?($data['sort']):99;
        $rdata['is_delete'] = 0;
        $rdata['wxapp_id'] = $data['wxapp_id']?($data['wxapp_id']):0;
        $rdata['shop_id'] = $data['shop_id']?($data['shop_id']):0;
        $rdata['bear_type'] = $data['bear_type']?($data['bear_type']):0;
        $rdata['shop_bear_rate'] = $data['shop_bear_rate']?($data['shop_bear_rate']):0;
        return $rdata;
    }
}